<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<script src="ajax.js"></script>
<script>
	function createPromise(url){
		return new Promise(function (resolve,reject) {
			//异步代码
			// resolve -成功了
			// reject - 失败了
			$.ajax({
				url,
				type:"get",
				success(data){
					resolve(data);
				},
				error(err){
					reject(err);
				}
			})
		});
	}
	Promise.all([
		createPromise("arr.txt"),createPromise("json.txt")
	]).then(function (arr) {
		let [res1,res2] = arr;
        console.log(res1,res2);
	},function () {

		alert("至少一个失败了");
	})

</script>
</body>
</html>